Replication instructions for "Measuring support for European integration using a Bayesian IRT model" 
Author: Michele Scotto di Vettimo; m.scotto-di-vettimo@exeter.ac.uk
Date 24-01-2022

Note: IRT models require JAGS installed on the computer: https://sourceforge.net/projects/mcmc-jags/
Running time vary according to machine's capacity and the number of raw indicators. I used a laptop with Intel Core i7 processor and a RAM of 32GB.

A) Description of the datasets

1. Files in "raw_indicators" folder. // Contain shares of supportive and neutral responses to the selected Eurobarometer items (these are the raw inputs to points B.1-3 and C.1)
2. "irt_estimates.dta" // The file contains the main IRT measures calculated under B.1 and B.2 (see below).
3. "main_data.dta" // The file contains the main IRT measures, plus it includes other public opinion measures used for comparison (see point C below)
4. "policy_areas.dta" // The file contains only the IRT measures calculated for four policy areas
5. "election_data.dta" // The file contains electoral data fro 265 national and European elections, along with three different public opinion measures (B.2, C.1, and C.4) and other control variables.
6. "irt_estimates_point_prior.dta" // Used for robustness checks. The file contains the main IRT measures calculated with an IRT model with different priors

B) To calculate IRT public opinion measures

1. Run "irt_model_eu_level.R" // This estimates EU-level public opinion measures and question parameters (running time: around 6 hours for main IRT series)
2. Run "irt_model_country_level.R" // Uses EU-level question parameters to estimate country-level public opinion meassures (running time: around 2 hours per country for main IRT series)
3. Run "irt_model_eu_level_notrust.R" // Same as 1., but excludes trust items (estimates used as robusteness check in appendix) (running time: 6 hours)
4. Run "irt_model_country_level_pointpriors.R" // Uses EU-level question parameters to estimate country-level public opinion measures (stored in A.6)

C) Other opinion measures

1. Dyad ratios algorithm estimates // Calculated using the same raw data in the folder "raw_indicators" and Stimson's DR algorithm (https://rdrr.io/github/davidaarmstrong/DyadRatios/f/vignettes/extract-vignette.Rmd) 
2. Anderson and Hecth's (2018) measures of public support // Authors' publicly available replication data: https://journals.sagepub.com/doi/suppl/10.1177/1465116518792306
3. Guidaudeau and Schnatterer's (2019) "European Mood" estimator // Authors' publicly available replication data: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/V42M9J
4. Membership question // Eurobarometer data
5. Other selected EB questions // Eurobarometer data

D) To reproduce the figures and the Tobit models

1. Run "replication_code.do". // This uses "main_data.dta", "policy_areas.dta", "election_data.dta" and "irt_estimates_point_prior.dta"

E) To get fit measures of IRT model

1. Run "fit_crossval_irt_model.R" // Script implements 5-fold cross-validation for the JAGS model. Requires data in "raw_indicators"